using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using ns18;
using ns20;

namespace Newtonsoft.Json
{
	public abstract class JsonWriter : IDisposable
	{
		internal enum State
		{
			Start,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			ConstructorStart,
			Constructor,
			Closed,
			Error
		}

		private static readonly State[][] state_0;

		internal static readonly State[][] state_1;

		private readonly List<Struct25> list_0;

		private Struct25 struct25_0;

		private State state_2;

		private Formatting formatting_0;

		private DateFormatHandling dateFormatHandling_0;

		private DateTimeZoneHandling dateTimeZoneHandling_0;

		private StringEscapeHandling stringEscapeHandling_0;

		private FloatFormatHandling floatFormatHandling_0;

		private string string_0;

		private CultureInfo cultureInfo_0;

		[CompilerGenerated]
		private bool bool_0;

		public bool CloseOutput
		{
			[CompilerGenerated]
			get
			{
				return bool_0;
			}
			[CompilerGenerated]
			set
			{
				bool_0 = value;
			}
		}

		protected internal int Top
		{
			get
			{
				int num = list_0.Count;
				if (method_3() != 0)
				{
					num++;
				}
				return num;
			}
		}

		public WriteState WriteState
		{
			get
			{
				switch (state_2)
				{
				default:
					throw JsonWriterException.smethod_1(this, "Invalid state: " + state_2, null);
				case State.Start:
					return WriteState.Start;
				case State.Property:
					return WriteState.Property;
				case State.ObjectStart:
				case State.Object:
					return WriteState.Object;
				case State.ArrayStart:
				case State.Array:
					return WriteState.Array;
				case State.ConstructorStart:
				case State.Constructor:
					return WriteState.Constructor;
				case State.Closed:
					return WriteState.Closed;
				case State.Error:
					return WriteState.Error;
				}
			}
		}

		internal string String_0
		{
			get
			{
				if (struct25_0.enum12_0 == Enum12.None)
				{
					return string.Empty;
				}
				return Struct25.smethod_1(list_0);
			}
		}

		public string Path
		{
			get
			{
				if (struct25_0.enum12_0 == Enum12.None)
				{
					return string.Empty;
				}
				IEnumerable<Struct25> ienumerable_ = ((state_2 == State.ArrayStart || state_2 == State.ConstructorStart || state_2 == State.ObjectStart) ? list_0 : list_0.Concat(new Struct25[1] { struct25_0 }));
				return Struct25.smethod_1(ienumerable_);
			}
		}

		public Formatting Formatting
		{
			get
			{
				return formatting_0;
			}
			set
			{
				formatting_0 = value;
			}
		}

		public DateFormatHandling DateFormatHandling
		{
			get
			{
				return dateFormatHandling_0;
			}
			set
			{
				dateFormatHandling_0 = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return dateTimeZoneHandling_0;
			}
			set
			{
				dateTimeZoneHandling_0 = value;
			}
		}

		public StringEscapeHandling StringEscapeHandling
		{
			get
			{
				return stringEscapeHandling_0;
			}
			set
			{
				stringEscapeHandling_0 = value;
				Newtonsoft_002EJson_002EJsonWriter_002E_202B_202B_200D_202C_206D_200B_200C_202E_206F_206C_202B_206C_200D_200F_202D_202C_202D_206A_206D_202A_202E_200D_206C_200B_202B_200B_206E_200C_206A_200B_200F_202E_202C_206C_202B_202B_202D_202D_206D_200F_202E();
			}
		}

		public FloatFormatHandling FloatFormatHandling
		{
			get
			{
				return floatFormatHandling_0;
			}
			set
			{
				floatFormatHandling_0 = value;
			}
		}

		public string DateFormatString
		{
			get
			{
				return string_0;
			}
			set
			{
				string_0 = value;
			}
		}

		public CultureInfo Culture
		{
			get
			{
				return cultureInfo_0 ?? CultureInfo.InvariantCulture;
			}
			set
			{
				cultureInfo_0 = value;
			}
		}

		internal static State[][] smethod_0()
		{
			List<State[]> list = state_1.ToList();
			State[] item = state_1[0];
			State[] item2 = state_1[7];
			foreach (JsonToken item3 in Class187.smethod_3(typeof(JsonToken)))
			{
				if (list.Count <= (int)item3)
				{
					switch (item3)
					{
					default:
						list.Add(item);
						break;
					case JsonToken.Integer:
					case JsonToken.Float:
					case JsonToken.String:
					case JsonToken.Boolean:
					case JsonToken.Null:
					case JsonToken.Undefined:
					case JsonToken.Date:
					case JsonToken.Bytes:
						list.Add(item2);
						break;
					}
				}
			}
			return list.ToArray();
		}

		static JsonWriter()
		{
			state_1 = new State[8][]
			{
				new State[10]
				{
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ObjectStart,
					State.ObjectStart,
					State.Error,
					State.Error,
					State.ObjectStart,
					State.ObjectStart,
					State.ObjectStart,
					State.ObjectStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ArrayStart,
					State.ArrayStart,
					State.Error,
					State.Error,
					State.ArrayStart,
					State.ArrayStart,
					State.ArrayStart,
					State.ArrayStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.ConstructorStart,
					State.ConstructorStart,
					State.Error,
					State.Error,
					State.ConstructorStart,
					State.ConstructorStart,
					State.ConstructorStart,
					State.ConstructorStart,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Property,
					State.Error,
					State.Property,
					State.Property,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Property,
					State.ObjectStart,
					State.Object,
					State.ArrayStart,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Property,
					State.ObjectStart,
					State.Object,
					State.ArrayStart,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				},
				new State[10]
				{
					State.Start,
					State.Object,
					State.Error,
					State.Error,
					State.Array,
					State.Array,
					State.Constructor,
					State.Constructor,
					State.Error,
					State.Error
				}
			};
			state_0 = smethod_0();
		}

		internal virtual void Newtonsoft_002EJson_002EJsonWriter_002E_202B_202B_200D_202C_206D_200B_200C_202E_206F_206C_202B_206C_200D_200F_202D_202C_202D_206A_206D_202A_202E_200D_206C_200B_202B_200B_206E_200C_206A_200B_200F_202E_202C_206C_202B_202B_202D_202D_206D_200F_202E()
		{
		}

		protected JsonWriter()
		{
			list_0 = new List<Struct25>(4);
			state_2 = State.Start;
			formatting_0 = Formatting.None;
			dateTimeZoneHandling_0 = DateTimeZoneHandling.RoundtripKind;
			CloseOutput = true;
		}

		internal void method_0()
		{
			if (struct25_0.bool_0)
			{
				struct25_0.int_0++;
			}
		}

		private void method_1(Enum12 enum12_0)
		{
			if (struct25_0.enum12_0 != 0)
			{
				list_0.Add(struct25_0);
			}
			struct25_0 = new Struct25(enum12_0);
		}

		private Enum12 method_2()
		{
			Struct25 @struct = struct25_0;
			if (list_0.Count > 0)
			{
				struct25_0 = list_0[list_0.Count - 1];
				list_0.RemoveAt(list_0.Count - 1);
			}
			else
			{
				struct25_0 = default(Struct25);
			}
			return @struct.enum12_0;
		}

		private Enum12 method_3()
		{
			return struct25_0.enum12_0;
		}

		public abstract void Flush();

		public virtual void Close()
		{
			method_8();
		}

		public virtual void WriteStartObject()
		{
			method_16(JsonToken.StartObject, Enum12.Object);
		}

		public virtual void WriteEndObject()
		{
			method_13(Enum12.Object);
		}

		public virtual void WriteStartArray()
		{
			method_16(JsonToken.StartArray, Enum12.Array);
		}

		public virtual void WriteEndArray()
		{
			method_13(Enum12.Array);
		}

		public virtual void WriteStartConstructor(string name)
		{
			method_16(JsonToken.StartConstructor, Enum12.Constructor);
		}

		public virtual void WriteEndConstructor()
		{
			method_13(Enum12.Constructor);
		}

		public virtual void WritePropertyName(string name)
		{
			method_14(name);
		}

		public virtual void WritePropertyName(string name, bool escape)
		{
			WritePropertyName(name);
		}

		public virtual void WriteEnd()
		{
			method_7(method_3());
		}

		public void WriteToken(JsonReader reader)
		{
			method_4(reader, bool_1: true, bool_2: true);
		}

		public void WriteToken(JsonReader reader, bool writeChildren)
		{
			Class204.smethod_2(reader, "reader");
			method_4(reader, writeChildren, bool_2: true);
		}

		internal void method_4(JsonReader jsonReader_0, bool bool_1, bool bool_2)
		{
			int int_ = ((jsonReader_0.JsonToken_0 == JsonToken.None) ? (-1) : (smethod_2(jsonReader_0.JsonToken_0) ? jsonReader_0.Int32_0 : (jsonReader_0.Int32_0 + 1)));
			method_5(jsonReader_0, int_, bool_1, bool_2);
		}

		internal void method_5(JsonReader jsonReader_0, int int_0, bool bool_1, bool bool_2)
		{
			do
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.Bytes:
					WriteValue((byte[])jsonReader_0.Object_0);
					goto case JsonToken.None;
				case JsonToken.None:
					if (int_0 - 1 >= jsonReader_0.Int32_0 - (smethod_1(jsonReader_0.JsonToken_0) ? 1 : 0) || !bool_1)
					{
						return;
					}
					break;
				case JsonToken.Date:
					if (jsonReader_0.Object_0 is DateTimeOffset)
					{
						WriteValue((DateTimeOffset)jsonReader_0.Object_0);
					}
					else
					{
						WriteValue(Convert.ToDateTime(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
					}
					goto case JsonToken.None;
				case JsonToken.EndConstructor:
					WriteEndConstructor();
					goto case JsonToken.None;
				case JsonToken.EndArray:
					WriteEndArray();
					goto case JsonToken.None;
				case JsonToken.EndObject:
					WriteEndObject();
					goto case JsonToken.None;
				case JsonToken.Undefined:
					WriteUndefined();
					goto case JsonToken.None;
				case JsonToken.Null:
					WriteNull();
					goto case JsonToken.None;
				case JsonToken.Boolean:
					WriteValue(Convert.ToBoolean(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
					goto case JsonToken.None;
				case JsonToken.String:
					WriteValue(jsonReader_0.Object_0.ToString());
					goto case JsonToken.None;
				case JsonToken.Float:
				{
					object object_ = jsonReader_0.Object_0;
					if (object_ is decimal)
					{
						WriteValue((decimal)object_);
					}
					else if (object_ is double)
					{
						WriteValue((double)object_);
					}
					else if (object_ is float)
					{
						WriteValue((float)object_);
					}
					else
					{
						WriteValue(Convert.ToDouble(object_, CultureInfo.InvariantCulture));
					}
					goto case JsonToken.None;
				}
				case JsonToken.Integer:
					if (jsonReader_0.Object_0 is BigInteger)
					{
						WriteValue((BigInteger)jsonReader_0.Object_0);
					}
					else
					{
						WriteValue(Convert.ToInt64(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
					}
					goto case JsonToken.None;
				case JsonToken.Raw:
					WriteRawValue((jsonReader_0.Object_0 != null) ? jsonReader_0.Object_0.ToString() : null);
					goto case JsonToken.None;
				case JsonToken.Comment:
					WriteComment((jsonReader_0.Object_0 != null) ? jsonReader_0.Object_0.ToString() : null);
					goto case JsonToken.None;
				case JsonToken.PropertyName:
					WritePropertyName(jsonReader_0.Object_0.ToString());
					goto case JsonToken.None;
				case JsonToken.StartConstructor:
				{
					string a = jsonReader_0.Object_0.ToString();
					if (bool_2 && string.Equals(a, "Date", StringComparison.Ordinal))
					{
						method_6(jsonReader_0);
					}
					else
					{
						WriteStartConstructor(jsonReader_0.Object_0.ToString());
					}
					goto case JsonToken.None;
				}
				case JsonToken.StartArray:
					WriteStartArray();
					goto case JsonToken.None;
				case JsonToken.StartObject:
					WriteStartObject();
					goto case JsonToken.None;
				default:
					throw Class194.smethod_1("TokenType", jsonReader_0.JsonToken_0, "Unexpected token type.");
				}
			}
			while (jsonReader_0.Read());
		}

		private void method_6(JsonReader jsonReader_0)
		{
			if (!jsonReader_0.Read())
			{
				throw JsonWriterException.smethod_1(this, "Unexpected end when reading date constructor.", null);
			}
			if (jsonReader_0.JsonToken_0 != JsonToken.Integer)
			{
				throw JsonWriterException.smethod_1(this, "Unexpected token when reading date constructor. Expected Integer, got " + jsonReader_0.JsonToken_0, null);
			}
			long long_ = (long)jsonReader_0.Object_0;
			DateTime value = Class185.smethod_11(long_);
			if (!jsonReader_0.Read())
			{
				throw JsonWriterException.smethod_1(this, "Unexpected end when reading date constructor.", null);
			}
			if (jsonReader_0.JsonToken_0 != JsonToken.EndConstructor)
			{
				throw JsonWriterException.smethod_1(this, "Unexpected token when reading date constructor. Expected EndConstructor, got " + jsonReader_0.JsonToken_0, null);
			}
			WriteValue(value);
		}

		internal static bool smethod_1(JsonToken jsonToken_0)
		{
			switch (jsonToken_0)
			{
			default:
				return false;
			case JsonToken.EndObject:
			case JsonToken.EndArray:
			case JsonToken.EndConstructor:
				return true;
			}
		}

		internal static bool smethod_2(JsonToken jsonToken_0)
		{
			switch (jsonToken_0)
			{
			default:
				return false;
			case JsonToken.StartObject:
			case JsonToken.StartArray:
			case JsonToken.StartConstructor:
				return true;
			}
		}

		private void method_7(Enum12 enum12_0)
		{
			switch (enum12_0)
			{
			default:
				throw JsonWriterException.smethod_1(this, "Unexpected type when writing end: " + enum12_0, null);
			case Enum12.Object:
				WriteEndObject();
				break;
			case Enum12.Array:
				WriteEndArray();
				break;
			case Enum12.Constructor:
				WriteEndConstructor();
				break;
			}
		}

		private void method_8()
		{
			while (Top > 0)
			{
				WriteEnd();
			}
		}

		private JsonToken method_9(Enum12 enum12_0)
		{
			return enum12_0 switch
			{
				Enum12.Object => JsonToken.EndObject, 
				Enum12.Array => JsonToken.EndArray, 
				Enum12.Constructor => JsonToken.EndConstructor, 
				_ => throw JsonWriterException.smethod_1(this, "No close token for type: " + enum12_0, null), 
			};
		}

		private void method_10(Enum12 enum12_0)
		{
			int num = 0;
			if (struct25_0.enum12_0 == enum12_0)
			{
				num = 1;
			}
			else
			{
				int num2 = Top - 2;
				int num3 = num2;
				while (num3 >= 0)
				{
					int index = num2 - num3;
					if (list_0[index].enum12_0 != enum12_0)
					{
						num3--;
						continue;
					}
					num = num3 + 2;
					break;
				}
			}
			if (num == 0)
			{
				throw JsonWriterException.smethod_1(this, "No token to close.", null);
			}
			for (int i = 0; i < num; i++)
			{
				JsonToken token = method_9(method_2());
				if (state_2 == State.Property)
				{
					WriteNull();
				}
				if (formatting_0 == Formatting.Indented && state_2 != State.ObjectStart && state_2 != State.ArrayStart)
				{
					WriteIndent();
				}
				WriteEnd(token);
				Enum12 @enum = method_3();
				switch (@enum)
				{
				case Enum12.None:
					state_2 = State.Start;
					break;
				case Enum12.Object:
					state_2 = State.Object;
					break;
				case Enum12.Array:
					state_2 = State.Array;
					break;
				case Enum12.Constructor:
					state_2 = State.Array;
					break;
				default:
					throw JsonWriterException.smethod_1(this, "Unknown JsonType: " + @enum, null);
				}
			}
		}

		protected virtual void WriteEnd(JsonToken token)
		{
		}

		protected virtual void WriteIndent()
		{
		}

		protected virtual void WriteValueDelimiter()
		{
		}

		protected virtual void WriteIndentSpace()
		{
		}

		internal void method_11(JsonToken jsonToken_0)
		{
			State state = state_0[(int)jsonToken_0][(int)state_2];
			if (state == State.Error)
			{
				throw JsonWriterException.smethod_1(this, "Token {0} in state {1} would result in an invalid JSON object.".smethod_1(CultureInfo.InvariantCulture, jsonToken_0.ToString(), state_2.ToString()), null);
			}
			if ((state_2 == State.Object || state_2 == State.Array || state_2 == State.Constructor) && jsonToken_0 != JsonToken.Comment)
			{
				WriteValueDelimiter();
			}
			if (formatting_0 == Formatting.Indented)
			{
				if (state_2 == State.Property)
				{
					WriteIndentSpace();
				}
				if (state_2 == State.Array || state_2 == State.ArrayStart || state_2 == State.Constructor || state_2 == State.ConstructorStart || (jsonToken_0 == JsonToken.PropertyName && state_2 != 0))
				{
					WriteIndent();
				}
			}
			state_2 = state;
		}

		public virtual void WriteNull()
		{
			method_17(JsonToken.Null);
		}

		public virtual void WriteUndefined()
		{
			method_17(JsonToken.Undefined);
		}

		public virtual void WriteRaw(string json)
		{
			method_15();
		}

		public virtual void WriteRawValue(string json)
		{
			method_0();
			method_11(JsonToken.Undefined);
			WriteRaw(json);
		}

		public virtual void WriteValue(string value)
		{
			method_17(JsonToken.String);
		}

		public virtual void WriteValue(int value)
		{
			method_17(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(uint value)
		{
			method_17(JsonToken.Integer);
		}

		public virtual void WriteValue(long value)
		{
			method_17(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ulong value)
		{
			method_17(JsonToken.Integer);
		}

		public virtual void WriteValue(float value)
		{
			method_17(JsonToken.Float);
		}

		public virtual void WriteValue(double value)
		{
			method_17(JsonToken.Float);
		}

		public virtual void WriteValue(bool value)
		{
			method_17(JsonToken.Boolean);
		}

		public virtual void WriteValue(short value)
		{
			method_17(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ushort value)
		{
			method_17(JsonToken.Integer);
		}

		public virtual void WriteValue(char value)
		{
			method_17(JsonToken.String);
		}

		public virtual void WriteValue(byte value)
		{
			method_17(JsonToken.Integer);
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(sbyte value)
		{
			method_17(JsonToken.Integer);
		}

		public virtual void WriteValue(decimal value)
		{
			method_17(JsonToken.Float);
		}

		public virtual void WriteValue(DateTime value)
		{
			method_17(JsonToken.Date);
		}

		public virtual void WriteValue(DateTimeOffset value)
		{
			method_17(JsonToken.Date);
		}

		public virtual void WriteValue(Guid value)
		{
			method_17(JsonToken.String);
		}

		public virtual void WriteValue(TimeSpan value)
		{
			method_17(JsonToken.String);
		}

		public virtual void WriteValue(int? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(uint? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(long? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ulong? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(float? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(double? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(bool? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(short? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(ushort? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(char? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(byte? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		[CLSCompliant(false)]
		public virtual void WriteValue(sbyte? value)
		{
			if (!((int?)value).HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(decimal? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(DateTime? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(DateTimeOffset? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(Guid? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(TimeSpan? value)
		{
			if (!value.HasValue)
			{
				WriteNull();
			}
			else
			{
				WriteValue(value.Value);
			}
		}

		public virtual void WriteValue(byte[] value)
		{
			if (value == null)
			{
				WriteNull();
			}
			else
			{
				method_17(JsonToken.Bytes);
			}
		}

		public virtual void WriteValue(Uri value)
		{
			if (value == null)
			{
				WriteNull();
			}
			else
			{
				method_17(JsonToken.String);
			}
		}

		public virtual void WriteValue(object value)
		{
			if (value == null)
			{
				WriteNull();
				return;
			}
			if (value is BigInteger)
			{
				throw smethod_4(this, value);
			}
			smethod_3(this, Class182.smethod_1(value), value);
		}

		public virtual void WriteComment(string text)
		{
			method_19();
		}

		public virtual void WriteWhitespace(string ws)
		{
			method_18(ws);
		}

		void IDisposable.Dispose()
		{
			method_12(bool_1: true);
		}

		private void method_12(bool bool_1)
		{
			if (state_2 != State.Closed)
			{
				Close();
			}
		}

		internal static void smethod_3(JsonWriter jsonWriter_0, Enum17 enum17_0, object object_0)
		{
			switch (enum17_0)
			{
			case Enum17.Char:
				jsonWriter_0.WriteValue((char)object_0);
				return;
			case Enum17.CharNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new char?((char)object_0));
				return;
			case Enum17.Boolean:
				jsonWriter_0.WriteValue((bool)object_0);
				return;
			case Enum17.BooleanNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new bool?((bool)object_0));
				return;
			case Enum17.SByte:
				jsonWriter_0.WriteValue((sbyte)object_0);
				return;
			case Enum17.SByteNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new sbyte?((sbyte)object_0));
				return;
			case Enum17.Int16:
				jsonWriter_0.WriteValue((short)object_0);
				return;
			case Enum17.Int16Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new short?((short)object_0));
				return;
			case Enum17.UInt16:
				jsonWriter_0.WriteValue((ushort)object_0);
				return;
			case Enum17.UInt16Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new ushort?((ushort)object_0));
				return;
			case Enum17.Int32:
				jsonWriter_0.WriteValue((int)object_0);
				return;
			case Enum17.Int32Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new int?((int)object_0));
				return;
			case Enum17.Byte:
				jsonWriter_0.WriteValue((byte)object_0);
				return;
			case Enum17.ByteNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new byte?((byte)object_0));
				return;
			case Enum17.UInt32:
				jsonWriter_0.WriteValue((uint)object_0);
				return;
			case Enum17.UInt32Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new uint?((uint)object_0));
				return;
			case Enum17.Int64:
				jsonWriter_0.WriteValue((long)object_0);
				return;
			case Enum17.Int64Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new long?((long)object_0));
				return;
			case Enum17.UInt64:
				jsonWriter_0.WriteValue((ulong)object_0);
				return;
			case Enum17.UInt64Nullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new ulong?((ulong)object_0));
				return;
			case Enum17.Single:
				jsonWriter_0.WriteValue((float)object_0);
				return;
			case Enum17.SingleNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new float?((float)object_0));
				return;
			case Enum17.Double:
				jsonWriter_0.WriteValue((double)object_0);
				return;
			case Enum17.DoubleNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new double?((double)object_0));
				return;
			case Enum17.DateTime:
				jsonWriter_0.WriteValue((DateTime)object_0);
				return;
			case Enum17.DateTimeNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new DateTime?((DateTime)object_0));
				return;
			case Enum17.DateTimeOffset:
				jsonWriter_0.WriteValue((DateTimeOffset)object_0);
				return;
			case Enum17.DateTimeOffsetNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new DateTimeOffset?((DateTimeOffset)object_0));
				return;
			case Enum17.Decimal:
				jsonWriter_0.WriteValue((decimal)object_0);
				return;
			case Enum17.DecimalNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new decimal?((decimal)object_0));
				return;
			case Enum17.Guid:
				jsonWriter_0.WriteValue((Guid)object_0);
				return;
			case Enum17.GuidNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new Guid?((Guid)object_0));
				return;
			case Enum17.TimeSpan:
				jsonWriter_0.WriteValue((TimeSpan)object_0);
				return;
			case Enum17.TimeSpanNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new TimeSpan?((TimeSpan)object_0));
				return;
			case Enum17.BigInteger:
				jsonWriter_0.WriteValue((BigInteger)object_0);
				return;
			case Enum17.BigIntegerNullable:
				jsonWriter_0.WriteValue((object_0 == null) ? null : new BigInteger?((BigInteger)object_0));
				return;
			case Enum17.Uri:
				jsonWriter_0.WriteValue((Uri)object_0);
				return;
			case Enum17.String:
				jsonWriter_0.WriteValue((string)object_0);
				return;
			case Enum17.Bytes:
				jsonWriter_0.WriteValue((byte[])object_0);
				return;
			case Enum17.DBNull:
				jsonWriter_0.WriteNull();
				return;
			}
			if (object_0 is IConvertible)
			{
				IConvertible convertible = (IConvertible)object_0;
				Class181 @class = Class182.smethod_2(convertible);
				object object_ = convertible.ToType(@class.Type_0, CultureInfo.InvariantCulture);
				smethod_3(jsonWriter_0, @class.Enum17_0, object_);
				return;
			}
			throw smethod_4(jsonWriter_0, object_0);
		}

		private static JsonWriterException smethod_4(JsonWriter jsonWriter_0, object object_0)
		{
			return JsonWriterException.smethod_1(jsonWriter_0, "Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".smethod_0(CultureInfo.InvariantCulture, object_0.GetType()), null);
		}

		protected void SetWriteState(JsonToken token, object value)
		{
			switch (token)
			{
			default:
				throw new ArgumentOutOfRangeException("token");
			case JsonToken.StartObject:
				method_16(token, Enum12.Object);
				break;
			case JsonToken.StartArray:
				method_16(token, Enum12.Array);
				break;
			case JsonToken.StartConstructor:
				method_16(token, Enum12.Constructor);
				break;
			case JsonToken.PropertyName:
				if (!(value is string))
				{
					throw new ArgumentException("A name is required when setting property name state.", "value");
				}
				method_14((string)value);
				break;
			case JsonToken.Comment:
				method_19();
				break;
			case JsonToken.Raw:
				method_15();
				break;
			case JsonToken.EndObject:
				method_13(Enum12.Object);
				break;
			case JsonToken.EndArray:
				method_13(Enum12.Array);
				break;
			case JsonToken.EndConstructor:
				method_13(Enum12.Constructor);
				break;
			case JsonToken.Integer:
			case JsonToken.Float:
			case JsonToken.String:
			case JsonToken.Boolean:
			case JsonToken.Null:
			case JsonToken.Undefined:
			case JsonToken.Date:
			case JsonToken.Bytes:
				method_17(token);
				break;
			}
		}

		internal void method_13(Enum12 enum12_0)
		{
			method_10(enum12_0);
		}

		internal void method_14(string string_1)
		{
			struct25_0.string_0 = string_1;
			method_11(JsonToken.PropertyName);
		}

		internal void method_15()
		{
		}

		internal void method_16(JsonToken jsonToken_0, Enum12 enum12_0)
		{
			method_0();
			method_11(jsonToken_0);
			method_1(enum12_0);
		}

		internal void method_17(JsonToken jsonToken_0)
		{
			method_0();
			method_11(jsonToken_0);
		}

		internal void method_18(string string_1)
		{
			if (string_1 != null && !Class199.smethod_4(string_1))
			{
				throw JsonWriterException.smethod_1(this, "Only white space characters should be used.", null);
			}
		}

		internal void method_19()
		{
			method_11(JsonToken.Comment);
		}
	}
}
